home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2009 May / maximum-cd-2009-05.iso / DiscContents / Firefox Setup 3.0.6.exe / nonlocalized / chrome / toolkit.jar / content / global / xml / XMLPrettyPrint.xsl < prev   
Encoding:
Extensible Markup Language  |  2007-05-15  |  5.4 KB  |  166 lines

  1. <?xml version="1.0"?>
  2. <!-- ***** BEGIN LICENSE BLOCK *****
  3.    - Version: MPL 1.1/GPL 2.0/LGPL 2.1
  4.    -
  5.    - The contents of this file are subject to the Mozilla Public License Version
  6.    - 1.1 (the "License"); you may not use this file except in compliance with
  7.    - the License. You may obtain a copy of the License at
  8.    - http://www.mozilla.org/MPL/
  9.    -
  10.    - Software distributed under the License is distributed on an "AS IS" basis,
  11.    - WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  12.    - for the specific language governing rights and limitations under the
  13.    - License.
  14.    -
  15.    - The Original Code is mozilla.org code.
  16.    -
  17.    - The Initial Developer of the Original Code is
  18.    - Netscape Communications Corporation.
  19.    - Portions created by the Initial Developer are Copyright (C) 2002
  20.    - the Initial Developer. All Rights Reserved.
  21.    -
  22.    - Contributor(s):
  23.    -   Jonas Sicking <sicking@bigfoot.com> (Original author)
  24.    -
  25.    - Alternatively, the contents of this file may be used under the terms of
  26.    - either the GNU General Public License Version 2 or later (the "GPL"), or
  27.    - the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  28.    - in which case the provisions of the GPL or the LGPL are applicable instead
  29.    - of those above. If you wish to allow use of your version of this file only
  30.    - under the terms of either the GPL or the LGPL, and not to allow others to
  31.    - use your version of this file under the terms of the MPL, indicate your
  32.    - decision by deleting the provisions above and replace them with the notice
  33.    - and other provisions required by the LGPL or the GPL. If you do not delete
  34.    - the provisions above, a recipient may use your version of this file under
  35.    - the terms of any one of the MPL, the GPL or the LGPL.
  36.    -
  37.    - ***** END LICENSE BLOCK ***** -->
  38.  
  39. <!DOCTYPE overlay SYSTEM "chrome://global/locale/xml/prettyprint.dtd">
  40.  
  41. <xsl:stylesheet version="1.0"
  42.                 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  43.                 xmlns="http://www.w3.org/1999/xhtml">
  44.  
  45.   <xsl:output method="xml"/>
  46.  
  47.   <xsl:template match="/">
  48.     <link href="chrome://global/content/xml/XMLPrettyPrint.css" type="text/css" rel="stylesheet"/>
  49.     <link title="Monospace" href="chrome://global/content/xml/XMLMonoPrint.css" type="text/css" rel="alternate stylesheet"/>
  50.     <div id="header">
  51.       <p>
  52.         &xml.nostylesheet;
  53.       </p>
  54.     </div>
  55.     <xsl:apply-templates/>
  56.   </xsl:template>
  57.  
  58.   <xsl:template match="*">
  59.     <div>
  60.       <xsl:text><</xsl:text>
  61.       <span class="start-tag"><xsl:value-of select="name(.)"/></span>
  62.       <xsl:apply-templates select="@*"/>
  63.       <xsl:text>/></xsl:text>
  64.     </div>
  65.   </xsl:template>
  66.  
  67.   <xsl:template match="*[node()]">
  68.     <div>
  69.       <xsl:text><</xsl:text>
  70.       <span class="start-tag"><xsl:value-of select="name(.)"/></span>
  71.       <xsl:apply-templates select="@*"/>
  72.       <xsl:text>></xsl:text>
  73.  
  74.       <span class="text"><xsl:value-of select="."/></span>
  75.  
  76.       <xsl:text></</xsl:text>
  77.       <span class="end-tag"><xsl:value-of select="name(.)"/></span>
  78.       <xsl:text>></xsl:text>
  79.     </div>
  80.   </xsl:template>
  81.  
  82.   <xsl:template match="*[* or processing-instruction() or comment() or string-length(.) > 50]">
  83.     <div class="expander-open">
  84.       <xsl:call-template name="expander"/>
  85.  
  86.       <xsl:text><</xsl:text>
  87.       <span class="start-tag"><xsl:value-of select="name(.)"/></span>
  88.       <xsl:apply-templates select="@*"/>
  89.       <xsl:text>></xsl:text>
  90.  
  91.       <div class="expander-content"><xsl:apply-templates/></div>
  92.  
  93.       <xsl:text></</xsl:text>
  94.       <span class="end-tag"><xsl:value-of select="name(.)"/></span>
  95.       <xsl:text>></xsl:text>
  96.     </div>
  97.   </xsl:template>
  98.  
  99.   <xsl:template match="@*">
  100.     <xsl:text> </xsl:text>
  101.     <span class="attribute-name"><xsl:value-of select="name(.)"/></span>
  102.     <xsl:text>=</xsl:text>
  103.     <span class="attribute-value">"<xsl:value-of select="."/>"</span>
  104.   </xsl:template>
  105.  
  106.   <xsl:template match="text()">
  107.     <xsl:if test="normalize-space(.)">
  108.       <xsl:value-of select="."/>
  109.     </xsl:if>
  110.   </xsl:template>
  111.  
  112.   <xsl:template match="processing-instruction()">
  113.     <div class="pi">
  114.       <xsl:text><?</xsl:text>
  115.       <xsl:value-of select="name(.)"/>
  116.       <xsl:text> </xsl:text>
  117.       <xsl:value-of select="."/>
  118.       <xsl:text>?></xsl:text>
  119.     </div>
  120.   </xsl:template>
  121.  
  122.   <xsl:template match="processing-instruction()[string-length(.) > 50]">
  123.     <div class="expander-open">
  124.       <xsl:call-template name="expander"/>
  125.  
  126.       <span class="pi">
  127.         <xsl:text> <?</xsl:text>
  128.         <xsl:value-of select="name(.)"/>
  129.       </span>
  130.       <div class="expander-content pi"><xsl:value-of select="."/></div>
  131.       <span class="pi">
  132.         <xsl:text>?></xsl:text>
  133.       </span>
  134.     </div>
  135.   </xsl:template>
  136.  
  137.   <xsl:template match="comment()">
  138.     <div class="comment">
  139.       <xsl:text><!--</xsl:text>
  140.       <xsl:value-of select="."/>
  141.       <xsl:text>--></xsl:text>
  142.     </div>
  143.   </xsl:template>
  144.  
  145.   <xsl:template match="comment()[string-length(.) > 50]">
  146.     <div class="expander-open">
  147.       <xsl:call-template name="expander"/>
  148.  
  149.       <span class="comment">
  150.         <xsl:text><!--</xsl:text>
  151.       </span>
  152.       <div class="expander-content comment">
  153.         <xsl:value-of select="."/>
  154.       </div>
  155.       <span class="comment">
  156.         <xsl:text>--></xsl:text>
  157.       </span> 
  158.     </div>
  159.   </xsl:template>
  160.   
  161.   <xsl:template name="expander">
  162.     <div class="expander">−</div>
  163.   </xsl:template>
  164.  
  165. </xsl:stylesheet>
  166.